<script setup lang="ts">
import resourceService from "../http/ResourceService";
import TheCommonTable from "../components/the-common-table.vue";

const columns = [
  {
    title: '名称',
    dataIndex: 'name',
    key: 'name'
  }, {
    title: '代码',
    dataIndex: 'code',
    key: 'code'
  }, {
    title: '请求方法',
    dataIndex: 'method',
    key: 'method'
  }, {
    title: 'Uri',
    dataIndex: 'uri',
    key: 'uri'
  }, {
    title: '状态',
    dataIndex: 'status',
    key: 'status'
  }, {
    title: '操作',
    key: 'action'
  }
]

const editingForm: FormItem[] = [
  {
    label: "名称",
    dataIndex: "name",
    inputType: "text",
    placeholder: "请输入名称"
  }, {
    label: "代码",
    dataIndex: "code",
    inputType: "text",
    placeholder: "请输入代码"
  }, {
    label: "请求方法",
    dataIndex: "method",
    inputType: "select",
    options: [{value: "GET"}, {value: "POST"}, {value: "PUT"}, {value: "DELETE"}, {value: "PATCH"}],
    placeholder: "请选择请求方法"
  }, {
    label: "Uri",
    dataIndex: "uri",
    inputType: "text",
    placeholder: "请输入请求地址"
  }, {
    label: "状态",
    dataIndex: "status",
    inputType: "radio",
    options: [{label: "启用", value: 1}, {label: "禁用", value: 0}]
  }
]
</script>

<template>
  <the-common-table :service="resourceService"
                    editing-value-key-name="code"
                    :columns="columns"
                    :editing-form="editingForm">
  </the-common-table>
</template>

<style scoped>

</style>